package com.mifengs.mall.adapter;

import android.graphics.Paint;
import android.support.annotation.Nullable;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.mifengs.mall.R;
import com.mifengs.mall.entity.GoodsBean;
import com.mifengs.mall.entity.ScareBuyingBean;
import com.mifengs.mall.util.ImageLoadUtil;

import java.util.List;

/**
 * Created by lihaoqi on 2017/12/20.
 */

public class MidTopListAdapter extends BaseQuickAdapter<GoodsBean,BaseViewHolder> {

    public MidTopListAdapter(@Nullable List<GoodsBean> data) {
        super(R.layout.item_goods,data);
    }

    @Override
    protected void convert(BaseViewHolder helper,GoodsBean item) {
        ImageView goodsImg = helper.getView(R.id.iv_img);
        ImageLoadUtil.displayImage(mContext,item.getImg(),goodsImg);
        double discount = Double.parseDouble(item.getDiscount())*10;
        helper.setText(R.id.tv_discount,discount+"折");
        helper.setText(R.id.tv_name,item.getGoodName());
        helper.setText(R.id.tv_xianjia,"¥"+item.getDiscountPrice());
        helper.setText(R.id.tv_yuanjia,"¥"+item.getOriginalCost());
        ((TextView) helper.getView(R.id.tv_yuanjia)).getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);
    }
}
